<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,javax.servlet.*,java.nio.file.Files "%>
<!DOCTYPE HTML>
<html>
<head>
<title>文件上传结果</title>



</head>
<body>
	<%
		String filepath = new String((request.getParameter("filepath")).getBytes("ISO-8859-1"),"UTF-8");
		System.out.println(filepath);
		String destpath = "D:\\test1\\";
		
		String temp[]=filepath.split("\\\\");
		destpath = destpath + temp[temp.length-1];
		System.out.println(destpath);
		
		File f1 = new File(filepath);
		File d1 = new File(destpath);
		if(d1.exists()){
			out.println("<h2>文件已存在</h2>");
		}
		else{
			Files.copy(f1.toPath(), d1.toPath());
			out.println("<h2>文件上传成功</h2>");
		}

	%>
	<form method="post" action="message.jsp" name="form1">
		选择一个文件:
    	<input type="file" name="filepath" id="filepath" >
    	<br/><br/>
    	<input type="submit" value="上传" >
	</form>
</body>
</html>